package gfx;

import javax.microedition.khronos.opengles.GL10;

import util.VertexBuffer;

public class Border {
	static float[] square = new float[12];
	
	public static void drawBorder(GL10 gl, float r, float g, float b, float a){		
		square[0] = -100;
		square[1] = -100;
		square[2] = 0;
		square[3] = 0;
		square[4] = -100;
		square[5] = 0;
		square[6] = -100;
		square[7] = 100;
		square[8] = 0;
		square[9] = 0;
		square[10] = 100;
		square[11] = 0;
		
		drawBit(gl, r, g, b, a);
		
		square[1] = square[4] = Camera.GL_HEIGHT;
		square[3] = square[9] = 100;
		
		drawBit(gl, r, g, b, a);
		
		square[0] = square[6] = Camera.GL_WIDTH;
		square[1] = square[4] = -100;
		
		drawBit(gl, r, g, b, a);
		
		square[7] = square[10] = 0;
		square[0] = square[6] = -100;
		
		drawBit(gl, r, g, b, a);
	}
	private static void drawBit(GL10 gl, float r, float g, float b, float a){		
		gl.glPushMatrix();
		gl.glDisable(GL10.GL_TEXTURE_2D);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glFrontFace(GL10.GL_CCW);
		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, VertexBuffer.getVertexBuffer(square));
		gl.glColor4f(r, g, b, a);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, square.length / 3);
		gl.glColor4f(1, 1, 1, 1);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glEnable(GL10.GL_TEXTURE_2D);
		gl.glPopMatrix();
	}
}
